import { Link } from '@brillout/docpress'
import { ConfigSpec } from '../../components'

<ConfigSpec
  env="build-time"
  global
/>

The `onPrerenderStart()` hook is called once when <Link href="/pre-rendering">pre-rendering</Link> starts.
It receives as argument an array of all <Link href="/pageContext">page contexts</Link> to be pre-rendered, and returns
a new array of page contexts, giving you a chance to add/remove/modify pages. This is usually used for
<Link href="/i18n">internationalization</Link>.

```ts
export { onPrerenderStart }

import type { PrerenderContext, PageContextServer } from 'vike/types'

async function onPrerenderStart(prerenderContext: PrerenderContext) {
  // new page contexts
  const pageContexts: PageContextServer[] = []

  // for each original page context:
  prerenderContext.pageContexts.forEach((pageContext) => {
    // for each locale, push a new page context to pageContexts
    // ...
  })

  return {
    prerenderContext: {
      pageContexts
    }
  }
}
```


## See also

- <Link href="/pre-rendering" />
- <Link href="/hooks" />
